package studia.figlewicz.math.library;
import java.util.Date;

public class Termin {
	
	Date data;
	
	public int dni;
	public int tygodnie;
	public int miesiace;
	public int lata;
	
	// konstruktory
	public Termin() {}
	public Termin(int dni, int tygodnie, int miesiace, int lata) {
		this.dni = dni;
		this.tygodnie = tygodnie;
		this.miesiace = miesiace;
		this.lata = lata;
	}
	public Termin(int dni) {
		this.dni = dni;
	}
	public Termin(Date data) {
		this.data = data;
		//this.data.setTime(0);
	}
	public Termin(Termin termin) {
		this.clone(termin);
	}
	
	
	// gettery i settery
	public Date getData() {
		return data;
	}
	public void setData(Date data) {
		this.data = data;
		//this.data.setTime(0);
	}
	
	
	// metody
	public int compareTo(Termin termin) {
		int resoult = this.data.compareTo(termin.data);
		return resoult;
	}

	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Termin other = (Termin) obj;
		if (data == null) {
			if (other.data != null)
				return false;
		} else if (!data.equals(other.data))
			return false;
		return true;
	}
	
	public Termin clone(Termin termin) {
		Termin nowy = new Termin();
		nowy.setData((Date)termin.getData().clone());
		return nowy;
	}
	
	public long ileDni() { // w konwencji _30/360
		long resoult = 0;
		resoult = resoult + lata*360;
		resoult = resoult + miesiace*30;
		resoult = resoult + tygodnie*7;
		resoult = resoult + dni;
		return resoult;
	}


	// metody statyczne
	public static Date ToDate(Termin termin) {
		return termin.data;
	}
	
}
